package br.fatec.ppi.entities.student;

import br.fatec.ppi.entities.ISearchable;
import br.fatec.ppi.entities.Student;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;

public abstract class SearchBy implements ISearchable<Student> {
    
    protected String query;
    
    public SearchBy(String query){
        this.query = query;
    }
    
    @Override
    public List<Student> doSearch() {
        EntityManager entityManager = Persistence.createEntityManagerFactory("schoolPersistenceModel").createEntityManager();
        return entityManager.createQuery(query).getResultList();
    }
}
